<?php
/**
 * This file is part of the Agora distribution. 
 * Detailed copyright and licensing information can be found
 * in the gpl-3.0.txt file which should be included in the distribution.
 * 
 * @version		$Id: 3.0.14 Olympus 2010-09-28 rammstein4o $
 * @copyright  2007 - 2010 jVitals
 * @license   GPLv3 Open Source
 * @link       http://jvitals.com
 * @since      File available since initial release
 */
defined( '_JEXEC' ) or die( 'Restricted access' );

@define ('IN_AGORA',1);
@define ('AGORA_DEBUG',0);
@define ('AGORA_TIME',time());
//define ('AGORA_HELP_TRANSLATE',1);

if (@AGORA_DEBUG === 1) {
	ini_set('display_errors', 1);
	error_reporting(E_ALL | E_NOTICE);
	ini_set('error_reporting', E_ALL | E_NOTICE);
	$dbo = & JFactory::getDBO();
	
	$dbo->debug(1);
	$begin_q = $dbo->getTicker();
	$begin = microtime(true);
}

@define ('AGORA_PATH',JPATH_COMPONENT_SITE.DS);
@define ('AGORA_CURRENT_PATH',JPATH_COMPONENT.DS);

//if (strpos(JPATH_COMPONENT,'administrator'.DS.'components'.DS.'com_agora'))
$JPATH_ADMIN = substr(JPATH_COMPONENT_SITE,0,strrpos(JPATH_COMPONENT_SITE,DS));
$JPATH_ADMIN = substr($JPATH_ADMIN,0,strrpos($JPATH_ADMIN,DS));
$JPATH_ADMIN .= DS.'administrator'.DS.'components'.DS.'com_agora';

define ('JPATH_ADMIN_COMPONENT',$JPATH_ADMIN);
require_once(JPATH_ADMIN_COMPONENT.DS.'upgrade.php');

require_once(AGORA_PATH.'include'.DS.'utils.php');
//ainclude('include|controller');
ainclude('model|model');
ainclude('include|agora.j15');
ainclude('include|dispatcher.j15');


$disp = AgoraDispatcher::getInstance();
$disp->route();
//$dispatcher->route($allowed_tasks);

$raw = JRequest::getVar('format') === 'raw';

if (@AGORA_DEBUG === 1 && !$raw) {
	$end = microtime(true);
	// $dbo was defined in line 11
	$end_q = $dbo->getTicker();

	print "Generated in ". round($end - $begin,3) . " sec. Queries: " . ($end_q - $begin_q);
}

//~ $doc =& JFactory::getDocument();
//~ $headerstuff = $doc->getHeadData();
//~ unset($headerstuff['scripts']['/plugins/system/mtupgrade/mootools.js']);
//~ $headerstuff['scripts'] = array_merge(array('/media/system/js/mootools.js' => 'text/javascript'), $headerstuff['scripts']);
//~ $doc->setHeadData($headerstuff);
